#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "WString.h"
#include "JSON.h"
#include "JSONContentListener.h"
#include "mock/JsonParserListenerMock.h"
using ::testing::Return;
using ::testing::InSequence;
//TODO
//shouldTrimSpace
//emptyMessage {}
//ignore rubbish
//parse sequence
//incomplete message
TEST(json, positiveTest){
		JsonParserListenerMock listenerMock;
		JsonParser p(listenerMock);
		String command = "{\"cmd\":\"light\", \"id\":\"kitchen\", \"state\":\"on\"}";
		{
			InSequence parse;
			EXPECT_CALL(listenerMock, onBegin());
			EXPECT_CALL(listenerMock, onItem(String("cmd"), String("light")))
				.Times(1)
				.WillOnce(Return(true));
			EXPECT_CALL(listenerMock, onItem(String("id"), String("kitchen")))
				.Times(1)
				.WillOnce(Return(true));
			EXPECT_CALL(listenerMock, onItem(String("state"), String("on")))
				.Times(1)
				.WillOnce(Return(true));
			EXPECT_CALL(listenerMock, onEnd());
		}
		
		p.parse(command);
}